<template>
  <div class="reportFormPage">
    <div class="report-dom">
      <el-row>
        <el-col :span="5" :offset="19">
          <div class="pageNumBox">
            <span>第</span>
            <span class="placeholder-min text-center">&nbsp;{{ form.page }}&nbsp;</span>
            <span>页，共</span>
            <span class="placeholder-min text-center">&nbsp;{{ form.totalPage }}&nbsp;</span>
            <span>页</span>
          </div>
        </el-col>
      </el-row>
      <div class="topTwoBox">
        <div class="centerName">路基路面压实度试验检测记录表(灌砂法)</div>
        <div class="codeText">
          <tr>
            JGLP01003a
          </tr>
        </div>
      </div>
      <div class="threeTopBox">
        <div class="left-border">
          <div class="box-title">检测单位名称：</div>
          <div class>{{ form.jiancdwmc }}</div>
        </div>
        <div class="right-border">
          <span>记录编号：</span>
          <span v-if="isPdf" class="placeholder">{{ form.jilbh }}</span>
          <el-input class="code-input" v-else type="text" v-model="form.jilbh" @focus="handleFocus('jilbh')" />
        </div>
      </div>
      <div class="table-border">
        <!-- .........................1111111111111111111111111111111......................................................... -->
        <table height="220px" class="top-table">
          <tbody>
            <tr>
              <td height="30" align="center" width="15%">
                <span style="width: 90px; display: inline-block">工程名称</span>
              </td>
              <td width="35%" class="text-center">
                <span>{{ form.gongcmc }}</span>
              </td>
              <td align="center" width="15%">
                <span style="width: 90px; display: inline-block">工程部位/用途</span>
              </td>
              <td width="35%" class="text-center">
                <span>{{ form.gongcbwyt }}</span>
              </td>
            </tr>
            <tr>
              <td height="50" align="center">样品信息</td>
              <td class="specimen-border" colspan="3">
                <span>样品名称：</span>
                <span :class="{ placeholder: !form.yangpmc }">{{ form.yangpmc }}</span>
                <span>；样品编号：</span>
                <span :class="{ 'placeholder-long': !form.yangpbh }">{{ form.yangpbh }}</span>
                <span>；检测点数：</span>
                <span :class="{ placeholder: !form.yangpsl }">{{ form.yangpsl }}</span>
                <span>；样品状态：</span>
                <span :class="{ placeholder: !form.yangpzt }">{{ form.yangpzt }}</span>
              </td>
            </tr>

            <tr>
              <td height="25" align="center" width="15%">
                <span style="width: 90px; display: inline-block">试验检测日期</span>
              </td>
               <!-- <td width="35%" class="text-center">{{ form.shiyjcrq }}</td> -->                                            
 <td width="35%" class="text-center">
      <el-input v-model="form.shiyjcrq" />
</td>
              <td align="center" width="15%">
                <span style="width: 90px; display: inline-block">试验条件</span>
              </td>
              <td v-if="isPdf" width="35%">
                温度：
                <span style="display: inline-block; width: 10%">{{ form.shiytjwd }}</span>
                ℃；湿度：
                <span style="display: inline-block; width: 10%">{{ form.shiytjsd }}</span
                >%RH
              </td>
              <td v-else width="35%">
                温度：
                <el-input :type="isPdf ? 'string' : 'number'" v-model="form.shiytjwd" style="width: 15%" />℃；湿度：
                <el-input :type="isPdf ? 'string' : 'number'" v-model="form.shiytjsd" style="width: 15%" />%RH
              </td>
            </tr>

            <tr>
              <td height="50" align="center" width="15%">
                <span style="width: 90px; display: inline-block">检测依据</span>
              </td>
              <td width="35%">
                <span v-if="isPdf">{{ form.jiancyj }}</span>
                <el-input v-else type="textarea" v-model="form.jiancyj" :rows="2" class="mark" @dblclick.native="showBsJiancyjView" readonly />
              </td>
              <td align="center" width="15%">
                <span style="width: 90px; display: inline-block">判定依据</span>
              </td>
              <td width="35%">
                <span v-if="isPdf">{{ form.pandyj }}</span>
                <el-input v-else type="textarea" v-model="form.pandyj" :rows="2" @dblclick.native="showBsJudgeBaseView" @focus="handleFocus('pandyj')" class="mark" />
              </td>
            </tr>
            <tr class="bottom-border">
              <td height="50" align="center">
                <div>主要仪器设备</div>
                <div>名称及编号</div>
              </td>
              <td colspan="3">
                <span v-if="isPdf">{{ form.zhuyyqsbmcjbh }}</span>
                <el-input v-else type="textarea" :rows="2" v-model="form.zhuyyqsbmcjbh" class="height100 width100 mark" @dblclick.native="showBsInstrumentView" readonly></el-input>
              </td>
            </tr>
          </tbody>
        </table>
        <!-- .................................22222222222222222222222222222222............................................... -->
        <table height="616px" class="middle-table">
          <tbody>
            <tr height="25">
              <td>设计压实度(%)</td>
              <td colspan="2"><el-input type="text" v-model="form.shejysd" @blur="setYsdgsfBgDataTop()" @keydown.native="handleKeyDown($event, 0, 0)" :ref="'0_0'" /></td>
              <td colspan="2">结构层位</td>
              <td colspan="4"><el-input type="text" v-model="form.jiegcw" @blur="setYsdgsfBgDataTop()" @keydown.native="handleKeyDown($event, 0, 1)" :ref="'0_1'" /></td>
            </tr>
            <tr height="25">
              <td>取样桩号、位置</td>
              <td colspan="2"><el-input type="text" v-model="form.detailList[0].qvyzhwz" @blur="setYsdgsfBgData()" @keydown.native="handleKeyDown($event, 1, 0)" :ref="'1_0'" /></td>
              <td colspan="2"><el-input type="text" v-model="form.detailList[2].qvyzhwz" @blur="setYsdgsfBgData()" @keydown.native="handleKeyDown($event, 1, 1)" :ref="'1_1'" /></td>
              <td colspan="2"><el-input type="text" v-model="form.detailList[4].qvyzhwz" @blur="setYsdgsfBgData()" @keydown.native="handleKeyDown($event, 1, 2)" :ref="'1_2'" /></td>
              <td colspan="2"><el-input type="text" v-model="form.detailList[6].qvyzhwz" @blur="setYsdgsfBgData()" @keydown.native="handleKeyDown($event, 1, 3)" :ref="'1_3'" /></td>
            </tr>
            <tr height="25">
              <td>试洞深度(cm)</td>
              <td colspan="2"><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[0].shidsd" @keydown.native="handleKeyDown($event, 2, 0)" :ref="'2_0'" /></td>
              <td colspan="2"><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[2].shidsd" @keydown.native="handleKeyDown($event, 2, 1)" :ref="'2_1'" /></td>
              <td colspan="2"><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[4].shidsd" @keydown.native="handleKeyDown($event, 2, 2)" :ref="'2_2'" /></td>
              <td colspan="2"><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[6].shidsd" @keydown.native="handleKeyDown($event, 2, 3)" :ref="'2_3'" /></td>
            </tr>
            <tr height="25">
              <td width="20%">盒号</td>
              <td width="10%"><el-input v-model="form.detailList[0].heh" class="pointer mark" @dblclick.native="showBaQjDetailView(0)" readonly /></td>
              <td width="10%"><el-input v-model="form.detailList[1].heh" class="pointer mark" @dblclick.native="showBaQjDetailView(1)" readonly /></td>
              <td width="10%"><el-input v-model="form.detailList[2].heh" class="pointer mark" @dblclick.native="showBaQjDetailView(2)" readonly /></td>
              <td width="10%"><el-input v-model="form.detailList[3].heh" class="pointer mark" @dblclick.native="showBaQjDetailView(3)" readonly /></td>
              <td width="10%"><el-input v-model="form.detailList[4].heh" class="pointer mark" @dblclick.native="showBaQjDetailView(4)" readonly /></td>
              <td width="10%"><el-input v-model="form.detailList[5].heh" class="pointer mark" @dblclick.native="showBaQjDetailView(5)" readonly /></td>
              <td width="10%"><el-input v-model="form.detailList[6].heh" class="pointer mark" @dblclick.native="showBaQjDetailView(6)" readonly /></td>
              <td width="10%"><el-input v-model="form.detailList[7].heh" class="pointer mark" @dblclick.native="showBaQjDetailView(7)" readonly /></td>
            </tr>
            <tr height="25">
              <td>盒质量(g)</td>
              <td><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[0].hezl" disabled /></td>
              <td><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[1].hezl" disabled /></td>
              <td><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[2].hezl" disabled /></td>
              <td><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[3].hezl" disabled /></td>
              <td><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[4].hezl" disabled /></td>
              <td><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[5].hezl" disabled /></td>
              <td><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[6].hezl" disabled /></td>
              <td><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[7].hezl" disabled /></td>
            </tr>
            <tr height="25">
              <td>盒+湿样质量(g)</td>
              <td><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[0].hesyzl" @blur="calculateHansl(0)" @keydown.native="handleKeyDown($event, 3, 0)" :ref="'3_0'" /></td>
              <td><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[1].hesyzl" @blur="calculateHansl(1)" @keydown.native="handleKeyDown($event, 3, 1)" :ref="'3_1'" /></td>
              <td><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[2].hesyzl" @blur="calculateHansl(2)" @keydown.native="handleKeyDown($event, 3, 2)" :ref="'3_2'" /></td>
              <td><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[3].hesyzl" @blur="calculateHansl(3)" @keydown.native="handleKeyDown($event, 3, 3)" :ref="'3_3'" /></td>
              <td><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[4].hesyzl" @blur="calculateHansl(4)" @keydown.native="handleKeyDown($event, 3, 4)" :ref="'3_4'" /></td>
              <td><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[5].hesyzl" @blur="calculateHansl(5)" @keydown.native="handleKeyDown($event, 3, 5)" :ref="'3_5'" /></td>
              <td><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[6].hesyzl" @blur="calculateHansl(6)" @keydown.native="handleKeyDown($event, 3, 6)" :ref="'3_6'" /></td>
              <td><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[7].hesyzl" @blur="calculateHansl(7)" @keydown.native="handleKeyDown($event, 3, 7)" :ref="'3_7'" /></td>
            </tr>
            <tr height="25">
              <td>盒+干样质量(g)</td>
              <td><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[0].hegyzl" @blur="calculateHansl(0)" @keydown.native="handleKeyDown($event, 4, 0)" :ref="'4_0'" /></td>
              <td><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[1].hegyzl" @blur="calculateHansl(1)" @keydown.native="handleKeyDown($event, 4, 1)" :ref="'4_1'" /></td>
              <td><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[2].hegyzl" @blur="calculateHansl(2)" @keydown.native="handleKeyDown($event, 4, 2)" :ref="'4_2'" /></td>
              <td><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[3].hegyzl" @blur="calculateHansl(3)" @keydown.native="handleKeyDown($event, 4, 3)" :ref="'4_3'" /></td>
              <td><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[4].hegyzl" @blur="calculateHansl(4)" @keydown.native="handleKeyDown($event, 4, 4)" :ref="'4_4'" /></td>
              <td><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[5].hegyzl" @blur="calculateHansl(5)" @keydown.native="handleKeyDown($event, 4, 5)" :ref="'4_5'" /></td>
              <td><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[6].hegyzl" @blur="calculateHansl(6)" @keydown.native="handleKeyDown($event, 4, 6)" :ref="'4_6'" /></td>
              <td><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[7].hegyzl" @blur="calculateHansl(7)" @keydown.native="handleKeyDown($event, 4, 7)" :ref="'4_7'" /></td>
            </tr>
            <tr height="25">
              <td>水分质量(g)</td>
              <td><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[0].shuifzl" disabled /></td>
              <td><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[1].shuifzl" disabled /></td>
              <td><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[2].shuifzl" disabled /></td>
              <td><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[3].shuifzl" disabled /></td>
              <td><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[4].shuifzl" disabled /></td>
              <td><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[5].shuifzl" disabled /></td>
              <td><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[6].shuifzl" disabled /></td>
              <td><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[7].shuifzl" disabled /></td>
            </tr>
            <tr height="25">
              <td>干样质量(g)</td>
              <td><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[0].ganyzl" disabled /></td>
              <td><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[1].ganyzl" disabled /></td>
              <td><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[2].ganyzl" disabled /></td>
              <td><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[3].ganyzl" disabled /></td>
              <td><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[4].ganyzl" disabled /></td>
              <td><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[5].ganyzl" disabled /></td>
              <td><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[6].ganyzl" disabled /></td>
              <td><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[7].ganyzl" disabled /></td>
            </tr>
            <tr height="25">
              <td>含水率(%)</td>
              <td><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[0].hansl" disabled /></td>
              <td><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[1].hansl" disabled /></td>
              <td><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[2].hansl" disabled /></td>
              <td><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[3].hansl" disabled /></td>
              <td><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[4].hansl" disabled /></td>
              <td><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[5].hansl" disabled /></td>
              <td><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[6].hansl" disabled /></td>
              <td><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[7].hansl" disabled /></td>
            </tr>
            <tr height="25">
              <td>平均含水率(%)</td>
              <td colspan="2"><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[0].pingjhsl" disabled /></td>
              <td colspan="2"><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[2].pingjhsl" disabled /></td>
              <td colspan="2"><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[4].pingjhsl" disabled /></td>
              <td colspan="2"><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[6].pingjhsl" disabled /></td>
            </tr>
            <tr height="25">
              <td>湿混合料质量(g)</td>
              <td colspan="2">
                <el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[0].shihhlzl" @blur="calculateShimd(0)" @keydown.native="handleKeyDown($event, 5, 0)" :ref="'5_0'" />
              </td>
              <td colspan="2">
                <el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[2].shihhlzl" @blur="calculateShimd(2)" @keydown.native="handleKeyDown($event, 5, 1)" :ref="'5_1'" />
              </td>
              <td colspan="2">
                <el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[4].shihhlzl" @blur="calculateShimd(4)" @keydown.native="handleKeyDown($event, 5, 2)" :ref="'5_2'" />
              </td>
              <td colspan="2">
                <el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[6].shihhlzl" @blur="calculateShimd(6)" @keydown.native="handleKeyDown($event, 5, 3)" :ref="'5_3'" />
              </td>
            </tr>
            <tr height="25">
              <td>灌砂前筒+砂质量(g)</td>
              <td colspan="2">
                <el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[0].guansqtszl" @blur="calculateGuanrsdnszl(0)" @keydown.native="handleKeyDown($event, 6, 0)" :ref="'6_0'" />
              </td>
              <td colspan="2">
                <el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[2].guansqtszl" @blur="calculateGuanrsdnszl(2)" @keydown.native="handleKeyDown($event, 6, 1)" :ref="'6_1'" />
              </td>
              <td colspan="2">
                <el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[4].guansqtszl" @blur="calculateGuanrsdnszl(4)" @keydown.native="handleKeyDown($event, 6, 2)" :ref="'6_2'" />
              </td>
              <td colspan="2">
                <el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[6].guansqtszl" @blur="calculateGuanrsdnszl(6)" @keydown.native="handleKeyDown($event, 6, 3)" :ref="'6_3'" />
              </td>
            </tr>
            <tr height="25">
              <td>灌砂后筒+砂质量(g)</td>
              <td colspan="2">
                <el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[0].guanshtszl" @blur="calculateGuanrsdnszl(0)" @keydown.native="handleKeyDown($event, 7, 0)" :ref="'7_0'" />
              </td>
              <td colspan="2">
                <el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[2].guanshtszl" @blur="calculateGuanrsdnszl(2)" @keydown.native="handleKeyDown($event, 7, 1)" :ref="'7_1'" />
              </td>
              <td colspan="2">
                <el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[4].guanshtszl" @blur="calculateGuanrsdnszl(4)" @keydown.native="handleKeyDown($event, 7, 2)" :ref="'7_2'" />
              </td>
              <td colspan="2">
                <el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[6].guanshtszl" @blur="calculateGuanrsdnszl(6)" @keydown.native="handleKeyDown($event, 7, 3)" :ref="'7_3'" />
              </td>
            </tr>
            <tr height="25">
              <td>锥体砂质量(g)</td>
              <td colspan="2">
                <el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[0].zhuitszl" @blur="calculateGuanrsdnszl(0)" @keydown.native="handleKeyDown($event, 8, 0)" :ref="'8_0'" />
              </td>
              <td colspan="2">
                <el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[2].zhuitszl" @blur="calculateGuanrsdnszl(2)" @keydown.native="handleKeyDown($event, 8, 1)" :ref="'8_1'" />
              </td>
              <td colspan="2">
                <el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[4].zhuitszl" @blur="calculateGuanrsdnszl(4)" @keydown.native="handleKeyDown($event, 8, 2)" :ref="'8_2'" />
              </td>
              <td colspan="2">
                <el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[6].zhuitszl" @blur="calculateGuanrsdnszl(6)" @keydown.native="handleKeyDown($event, 8, 3)" :ref="'8_3'" />
              </td>
            </tr>
            <tr height="25">
              <td>灌入试洞内砂质量(g)</td>
              <td colspan="2"><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[0].guanrsdnszl" disabled /></td>
              <td colspan="2"><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[2].guanrsdnszl" disabled /></td>
              <td colspan="2"><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[4].guanrsdnszl" disabled /></td>
              <td colspan="2"><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[6].guanrsdnszl" disabled /></td>
            </tr>
            <tr height="25">
              <td>标准砂密度(g/cm³)</td>
              <td colspan="2">
                <el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[0].biaozsmd" @blur="calculateShidtj(0)" @keydown.native="handleKeyDown($event, 9, 0)" :ref="'9_0'" />
              </td>
              <td colspan="2">
                <el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[2].biaozsmd" @blur="calculateShidtj(2)" @keydown.native="handleKeyDown($event, 9, 1)" :ref="'9_1'" />
              </td>
              <td colspan="2">
                <el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[4].biaozsmd" @blur="calculateShidtj(4)" @keydown.native="handleKeyDown($event, 9, 2)" :ref="'9_2'" />
              </td>
              <td colspan="2">
                <el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[6].biaozsmd" @blur="calculateShidtj(6)" @keydown.native="handleKeyDown($event, 9, 3)" :ref="'9_3'" />
              </td>
            </tr>
            <tr height="25">
              <td>试洞体积(cm³)</td>
              <td colspan="2"><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[0].shidtj" disabled /></td>
              <td colspan="2"><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[2].shidtj" disabled /></td>
              <td colspan="2"><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[4].shidtj" disabled /></td>
              <td colspan="2"><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[6].shidtj" disabled /></td>
            </tr>
            <tr height="25">
              <td>湿密度(g/cm³)</td>
              <td colspan="2"><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[0].shimd" disabled /></td>
              <td colspan="2"><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[2].shimd" disabled /></td>
              <td colspan="2"><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[4].shimd" disabled /></td>
              <td colspan="2"><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[6].shimd" disabled /></td>
            </tr>
            <tr height="25">
              <td>干密度(g/cm³)</td>
              <td colspan="2"><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[0].ganmd" disabled /></td>
              <td colspan="2"><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[2].ganmd" disabled /></td>
              <td colspan="2"><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[4].ganmd" disabled /></td>
              <td colspan="2"><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[6].ganmd" disabled /></td>
            </tr>
            <tr height="25">
              <td>最大干密度(g/cm³)</td>
              <td colspan="2">
                <el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[0].zuidgmd" @blur="calculateYasd(0)" @keydown.native="handleKeyDown($event, 10, 0)" :ref="'10_0'" />
              </td>
              <td colspan="2">
                <el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[2].zuidgmd" @blur="calculateYasd(2)" @keydown.native="handleKeyDown($event, 10, 1)" :ref="'10_1'" />
              </td>
              <td colspan="2">
                <el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[4].zuidgmd" @blur="calculateYasd(4)" @keydown.native="handleKeyDown($event, 10, 2)" :ref="'10_2'" />
              </td>
              <td colspan="2">
                <el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[6].zuidgmd" @blur="calculateYasd(6)" @keydown.native="handleKeyDown($event, 10, 3)" :ref="'10_3'" />
              </td>
            </tr>
            <tr height="25">
              <td>压实度(%)</td>
              <td colspan="2"><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[0].yasd" disabled /></td>
              <td colspan="2"><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[2].yasd" disabled /></td>
              <td colspan="2"><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[4].yasd" disabled /></td>
              <td colspan="2"><el-input :type="isPdf ? 'string' : 'number'" v-model="form.detailList[6].yasd" disabled /></td>
            </tr>
          </tbody>
        </table>
        <!-- .....................................................33333333333333333................................................... -->
        <table height="60px" class="bottom-table">
          <tr>
            <td>
              <span v-if="isPdf" class="textarea-span">{{ form.fujsm }}</span>
              <el-input v-else type="textarea" :rows="2" v-model="form.fujsm" @focus="handleFocus('fujsm')" />
            </td>
          </tr>
        </table>
      </div>
      <!-- .................................44444444444............................................. -->
      <table height="22px" class="transparent">
        <tbody>
          <tr>
            <td width="10%" align="right">检测：</td>
            <td width="15%" align="left"></td>
            <td width="10%" align="right">记录：</td>
            <td width="15%" align="left"></td>
            <td width="10%" align="right">复核：</td>
            <td align="left" width="15%"></td>
            <td width="10%">日期：</td>
            <td align="left" width="15%">
              <div style="display: inline-block; margin-left: 20px">年</div>
              <div style="display: inline-block; margin-left: 20px">月</div>
              <div style="display: inline-block; margin-left: 20px">日</div>
            </td>
          </tr>
        </tbody>
      </table>
    </div>
    <bs-instrument-view ref="bsInstrumentViewRef" @select="selectInstrument"></bs-instrument-view>
    <bs-jiancyj-view ref="bsJiancyjViewRef" @select="selectJiancyj" :syType="syType"></bs-jiancyj-view>
    <bs-judge-base-view ref="bsJudgeBaseViewRef" @select="selectJudge" :syType="syType"></bs-judge-base-view>
    <ba-qj-detail-view ref="baQjDetailViewRef" :excelId="excelId" :shiyjcrq="form.shiyjcrq" @select="selectBaQjDetail"></ba-qj-detail-view>
  </div>
</template>

<script>
import { getYsdgsfjlbBsInfo } from "@/api/report_ljlm/ysdgsfjlbBsInfo";
import BsInstrumentView from "@/views/dept/bsInstrument/BsInstrumentView.vue";
import BaQjDetailView from "@/views/sycs/baQjDetail/BaQjDetailView.vue";
import BsJiancyjView from "@/views/sycs/bsJiancyj/BsJiancyjView.vue";
import BsJudgeBaseView from "@/views/sycs/bsJudgeBase/BsJudgeBaseView.vue";

import decimal from "@/utils/big-decimal";
import { handleFocus, emptyConvert, calculateMeanvalue, handleKeyDown } from "@/views/reportForms/utils";
import Bus from "@/utils/bus";
import { setBljw, getDecimalWs } from "../components/decimalScheme.js";

export default {
  name: "ysdgsfjlb",
  components: {
    BsInstrumentView,
    BaQjDetailView,
    BsJiancyjView,
    BsJudgeBaseView
  },
  props: {
    excelId: {
      type: [String, Number],
      default: () => ""
    },
    syType: {
      type: [String, Number],
      default: () => ""
    },
    page: {
      type: Number,
      default: () => 0
    },
    isPdf: {
      type: Boolean,
      default: () => false
    },
    printEmpty: {
      type: Boolean,
      default: () => false
    }
  },
  data() {
    return {
      // 表单参数
      form: {
        detailList: [{}, {}, {}, {}, {}, {}, {}, {}]
      },
      detailVos: []
    };
  },
  watch: {
    isPdf(newVal, oldVal) {
      this.form = { ...emptyConvert(this.form, newVal) };
    }
  },
  created() {
    this.getInfo();
  },
  mounted() {
    // 获取顶部数据
    Bus.$on("setYsdgsfBgDataTop", (data) => {
      for (const key in data) {
        if (Object.prototype.hasOwnProperty.call(data, key)) {
          this.form[key] = data[key];
        }
      }
    });
    Bus.$on("setXsd", (data) => {
      this.getInfo();
      this.$modal.msgSuccess("设使用成功");
    });
  },

  beforeDestroy() {
    Bus.$off("setYsdgsfBgDataTop");
    Bus.$off("setXsd");
  },

  methods: {
    setBljw,
    getDecimalWs,
    // 获取详情
    getInfo() {
      getYsdgsfjlbBsInfo(this.excelId || this.$defaultExcelId).then((response) => {
        this.form = response.data;
        this.detailVos = this.setBljw(response.data.fanganVo?.detailVos || []);
        if (this.detailVos?.length) {
          this.setXsdFA();
        }
        if (!this.form.fujsm) {
          this.form.fujsm = "附加声明：";
        }
      });
    },
    // 显示检测依据列表
    showBsJiancyjView() {
      this.$refs.bsJiancyjViewRef.init(this.form.jiancyjIds);
    },
    // 检测依据选择
    selectJiancyj(info) {
      this.form.jiancyj = info.label;
      this.form.jiancyjIds = info.ids;
      Bus.$emit("setYsdgsfBgJiancyj", { jiancyj: this.form.jiancyj, jiancyjIds: this.form.jiancyjIds });
    },
    // 显示判定依据列表
    showBsJudgeBaseView() {
      this.$refs.bsJudgeBaseViewRef.init(this.form.pandyjIds);
    },
    // 判断依据选择
    selectJudge(info) {
       this.form.pandyjIds = info.ids;
      this.form.pandyj = info.label;
    },
    // 显示仪器列表
    showBsInstrumentView() {
      this.$refs.bsInstrumentViewRef.init(this.form.shebIds);
    },
    // 仪器选择
    selectInstrument(info) {
      this.form.zhuyyqsbmcjbh = info.label;
      this.form.shebIds = info.ids;
      Bus.$emit("setYsdgsfBgZhuyyqsbmcjbh", { zhuyyqsbmcjbh: this.form.zhuyyqsbmcjbh, shebIds: this.form.shebIds });
    },
    // 显示盒号列表
    showBaQjDetailView(index) {
      this.collectHehId();
      this.$refs.baQjDetailViewRef.init(index, this.form.hehIdList);
    },
    // 盒号选择
    selectBaQjDetail(index, obj) {
      this.form.detailList[index].heh = obj.hh;
      this.form.detailList[index].hehId = obj.detailId;
      this.form.detailList[index].hezl = obj.quality;
      this.calculateHansl(index);
    },
    // 计算含水率
    calculateHansl(index) {
      // 计算水质量
      const hezl = this.form.detailList[index].hezl; // 盒质量
      const hesyzl = this.form.detailList[index].hesyzl; // 盒+湿样质量
      const hegyzl = this.form.detailList[index].hegyzl; // 盒+干样质量
      let shuifzl = null; // 水分质量
      let ganyzl = null; // 干样质量
      let hansl = null; // 含水率
      if (hesyzl && hegyzl) {
        // 水分质量(g) = (盒+湿土质量(g)) -(盒+干土质量(g))
        shuifzl = decimal.subtract(hesyzl, hegyzl, 1);
      }
      if (hegyzl && hezl) {
        // 干土质量（g） = (盒+干土质量(g)) -(盒质量(g))
        ganyzl = decimal.subtract(hegyzl, hezl, 1);
      }
      if (shuifzl && ganyzl) {
        // 含水率(%) = (水分质量(g)) / (干土质量（g）) * 100%
        hansl = decimal.multiply(decimal.divide(shuifzl, ganyzl, 10), 100, 1);
      }
      this.form.detailList[index].shuifzl = shuifzl;
      this.form.detailList[index].ganyzl = ganyzl;
      this.form.detailList[index].hansl = hansl;
      // 平均含水率
      this.calculatePingjhsl(index);
    },
    // 计算平均含水率
    calculatePingjhsl(index) {
      let indexArr = [index, index % 2 == 0 ? index + 1 : index - 1];
      let arr = [];
      indexArr.forEach((key) => {
        const hansl = this.form.detailList[key].hansl;
        if (hansl) {
          arr.push(hansl);
        }
      });
      const newIndex = index % 2 == 0 ? index : index - 1;
      this.form.detailList[newIndex].pingjhsl = calculateMeanvalue(arr);
      // 计算干密度
      this.calculateGanmd(index);
    },
    // 计算灌入试洞内砂质量
    calculateGuanrsdnszl(index) {
      // D=A-B-C
      const A = this.form.detailList[index].guansqtszl;
      const B = this.form.detailList[index].guanshtszl;
      const C = this.form.detailList[index].zhuitszl;
      let D = null;
      if (A && B && C) {
        D = decimal.subtract(A, decimal.add(B, C));
      }
      this.form.detailList[index].guanrsdnszl = D;
      this.calculateShidtj(index);
    },
    // 计算试洞体积
    calculateShidtj(index) {
      // F=D/E
      const D = this.form.detailList[index].guanrsdnszl;
      const E = this.form.detailList[index].biaozsmd;
      let F = null;
      if (D && E) {
        F = decimal.divide(D, E);
      }
      this.form.detailList[index].shidtj = F;
      this.calculateShimd(index);
    },
    // 计算湿密度
    calculateShimd(index) {
      // H=G/F
      const G = this.form.detailList[index].shihhlzl;
      const F = this.form.detailList[index].shidtj;
      let H = null;
      if (G && F) {
        let num = this.getDecimalWs(this.detailVos, "shimd", 3);
        H = decimal.divide(G, F, num);
      }
      this.form.detailList[index].shimd = H;
      // 计算干密度
      this.calculateGanmd(index);
    },
    // 计算干密度
    calculateGanmd(index) {
      // J=H/(1+0.01W)
      const H = this.form.detailList[index].shimd;
      const W = this.form.detailList[index].pingjhsl;
      let J = null;
      if (H && W) {
        let num = this.getDecimalWs(this.detailVos, "ganmd", 3);
        J = decimal.divide(H, decimal.add(1, decimal.multiply(0.01, W, 10), 10), num);
      }
      this.form.detailList[index].ganmd = J;
      this.calculateYasd(index);
    },
    // 计算压实度
    calculateYasd(index) {
      // N=100*J/M
      const J = this.form.detailList[index].ganmd;
      const M = this.form.detailList[index].zuidgmd;
      let N = null;
      if (J && M) {
        N = decimal.divide(decimal.multiply(100, J, 10), M, 1);
      }
      this.form.detailList[index].yasd = N;
      this.setYsdgsfBgData();
    },
    setYsdgsfBgData() {
      Bus.$emit("setYsdgsfBgData", this.getBgData());
    },
    getBgData() {
      let arr = [];
      this.form.detailList.forEach((item, index) => {
        if (index % 2 == 0) {
          arr.push({
            qvyzhwz: item.qvyzhwz,
            yasd: item.yasd
          });
        }
      });
      return arr;
    },
    setYsdgsfBgDataTop() {
      const info = {
        shejysd: this.form.shejysd,
        yasdsjz: this.form.shejysd,
        jiegcw: this.form.jiegcw
      };
      Bus.$emit("setYsdgsfBgDataTop", info);
    },
    // 汇总盒号id
    collectHehId() {
      let hehIdList = [];
      this.form.detailList.forEach((item) => {
        if (item.heh) {
          hehIdList.push(item.hehId);
        }
      });
      this.form.hehIdList = hehIdList;
    },
    submitForm() {
      this.collectHehId();
      return this.form;
    },
    handleFocus(event) {
      handleFocus(event, this.page, this.form[event]);
    },
    handleKeyDown(event, rowIndex, colIndex) {
      const maxArr = [1, 3, 3, 7, 7, 3, 3, 3, 3, 3, 3];
      const ref = handleKeyDown(event, rowIndex, colIndex, maxArr);
      if (this.$refs[ref]?.length) {
        this.$refs[ref][0].focus();
      } else if (this.$refs[ref]) {
        this.$refs[ref].focus();
      }
    },
    // 计算方法调用
    setCalculate(name, a, b, c, d, e) {
      this[name](a, b, c, d, e);
    },
    // 小数点方案使用调用方法
    setXsdFA() {
      const subAllArr = [0, 2, 4, 6];
      for (let a = 0; a < subAllArr.length; a++) {
        this.setCalculate("calculateShimd", subAllArr[a]);
      }
    }
  }
};
</script>

<style scoped></style>
